<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    /**
     * @param {number[]} nums
     * @param {number} k
     * @return {boolean}
     */
    var containsNearbyDuplicate = function(nums, k) {
      let falg = false;
      let hash = {};
      for (let i = 0; i < nums.length; i++) {
        for (let j = 0; j < nums.length; j++) {
          if (nums[i] == nums[j] && Math.abs(i - j) <= k && i != j) {
            return (falg = true);
          }
        }
      }
      return falg;
    };
    console.log(containsNearbyDuplicate([1, 2, 3, 1, 2, 3], 2));
  </script>
</html>
